package com.bm.controller;

import com.bm.Result.Result;
import com.bm.Vo.Fitment.DetailFitmentVo;
import com.bm.Vo.Fitment.FitmentListVo;
import com.bm.model.EjyyFitment;
import com.bm.query.Fitment.FitmentAgreeQuery;
import com.bm.query.Fitment.FitmentListQuery;
import com.bm.service.EjyyFitmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 86134
 * @version 1.0
 * @description TODO
 * @date 2024/3/5 19:59
 */
@RestController
@Api(tags = "装修相关api")
public class FitmentController {

    @Autowired
    private EjyyFitmentService ejyyFitmentService;

    @PostMapping("/fitment/list")
    @ApiOperation(value = "查询装修信息api")
    public Result FitmentListController(@RequestBody FitmentListQuery fitmentListQuery) {
        List<FitmentListVo> list = ejyyFitmentService.FitmentList(fitmentListQuery);
        return Result.OK(list);
    }

    @PostMapping("/fitment/create")
    @ApiOperation(value = "新增装修报备api")
    public Result CreateFitment(@RequestBody EjyyFitment ejyyFitment) {
        boolean flag = ejyyFitmentService.insertFitment(ejyyFitment);
        return flag ? Result.OK() : Result.FAIL();
    }

    @PostMapping("/fitment/agree")
    @ApiOperation(value = "同意装修申请api")
    public Result fitmentAgree(@RequestBody FitmentAgreeQuery fitmentAgreeQuery){
        boolean flag = ejyyFitmentService.updateFitmentAgree(fitmentAgreeQuery);
        return flag ? Result.OK():Result.FAIL();
    }
    @PostMapping("/fitment/detail")
    @ApiOperation(value = "获取装修登记信息 (只需要id 和 Community id)")
    public Result DetailFitment(@RequestBody EjyyFitment ejyyFitment){
        DetailFitmentVo detailFitmentVo = ejyyFitmentService.detailFitment(ejyyFitment);
        return Result.OK(detailFitmentVo);
    }

    @PostMapping("/fitment/confirm")
    @ApiOperation(value = "装修确认完工api (只需要id 和 Community id)")
    public Result FitmentConfirm(@RequestBody EjyyFitment ejyyFitment){
        boolean flag = ejyyFitmentService.fitmentConfirm(ejyyFitment);
        return flag ? Result.OK() : Result.FAIL();
    }

    @PostMapping("/fitment/return")
    @ApiOperation("确认装修保证金是否放还api (只需要id 和 Community id)")
    public Result FitmentReturn(@RequestBody EjyyFitment ejyyFitment){
        boolean flag = ejyyFitmentService.fitmentReturn(ejyyFitment);
        return flag ? Result.OK() : Result.FAIL();
    }


}
